package com.bitmain.mmst.web.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bitmain.mmst.common.consts.ResultCode.ERROR;
import com.bitmain.mmst.common.consts.ResultCode.INFO;
import com.bitmain.mmst.core.struct.DictionaryItem;
import com.bitmain.mmst.core.struct.ServiceResult;
import com.bitmain.mmst.domain.PreferenceGeneral;
import com.bitmain.mmst.web.dao.PreferenceDao;

/**
 * 
 *
 * @author Richard - rui.wu@bitmain.com
 * @since 2016年8月10日 
 *
 */
@Service("preferenceService")
public class PreferenceService {

	@Autowired
	private PreferenceDao preferenceDao;
	
	public ServiceResult<PreferenceGeneral> fetchGeneral() {
		ServiceResult<PreferenceGeneral> result = new ServiceResult<PreferenceGeneral>();
		DictionaryItem item = preferenceDao.selectGenal();
		if(item!=null){
			PreferenceGeneral general = item.getValue(PreferenceGeneral.class);
			result.setInfo(INFO.INFO);
			result.setData(general);
		}else{
			result.setError(ERROR.DB_SELECT);
		}
		return result;
	}
}
